<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <link rel="stylesheet" href="css/tableRound.css">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/bootstrap-table.css">
    <style>
        .fixed-table-pagination .page-list {
            right: 220px;
        }

        .fixed-table-pagination div.pagination,
        .fixed-table-pagination .pagination-detail {
            right: 290px;
        }

        .fixed-table-toolbar{
            display: inline-block;
            position: fixed;
            top: 52px;
            right: 20px;
        }

        .fixed-table-toolbar .search{
            margin: 0;
        }

        .fixed-table-toolbar .form-control{
            height: 28px;
        }
    </style>
</head>
<body>
<div id="coverTable">
    <select id="coverTableSelect"></select>
    <select id="coverTableType"></select>
    <select id="coverTablevillage"></select>
    <input class="query-pulp" id="query1" type="button" value="查询">
    <button class="performance" style="right: 120px;">护士绩效</button>
    <button class="submit-table">提交修改</button>
    <div class="show-title">
        <h1></h1>
    </div>
    <div class="table-responsive">
        <table id="thisTown" class="table"></table>
    </div>
    <div class="table-responsive">
        <table id="table"></table>
    </div>
</div>
<div id="popup" class="popup" style="display: none;">
    <h1></h1>
    <img src="images/close.png" width="27px" onclick="closePopup()" alt="关闭">
    <div class="popup-content"></div>
</div>
<div id="popup1" class="popup" style="display: none;">
    <h1></h1>
    <img src="images/close.png" width="27px" onclick="closePopup1()" alt="关闭">
    <div class="popup-content"></div>
</div>

</body>
<script src="js/jquery.min.js"></script>
<script src="js/echarts4.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap-table.js"></script>
<script src="js/template.js"></script>
<script src="js/vii-placeholder.js"></script>
<script src="js/common.js"></script>
<script src="js/tableCommon.js"></script>
<script>
    /*
    * getPerformanceDetails
    * 获取护士绩效数据
    * */
    function getPerformanceDetails(cardID, callback) {
        $.ajax({
            url: "http://60.164.210.223:7577/Nvr/map/getNurseAchievements",
            dataType: "jsonp",
            data: {
                nurseId: cardID
            },
            beforeSend: function () {
                placeholder.show(document.body);
            },
            success: function (item) {

                console.log(JSON.stringify(item))

                callback(item);
            },
            error: function (error) {
                alert("绩效详情请求失败！");
                placeholder.hide(document.body);
                $(".vii-holder-mask").hide();
            }
        });
    }

    /*
    * getJobPerformanceDetails
    * 获取护士岗位绩效详情数据
    * */
    function getJobPerformanceDetails(cardID, month, callback) {
        $.ajax({
            url: "http://60.164.210.223:7577/Nvr/map/getNursePostWagesDetail",
            dataType: "jsonp",
            data: {
                nurseId: cardID,
                month: month
            },
            beforeSend: function () {
                placeholder.show(document.body);
            },
            success: function (item) {
                callback(item);
            },
            error: function (error) {
                alert("岗位绩效详情请求失败！");
                placeholder.hide(document.body);
                $(".vii-holder-mask").hide();
            }
        });
    }

    /*
    * getDevelopeDetails
    * 获取护士血源发展绩效详情数据
    * */
    function getDevelopeDetails(cardID, month, callback) {
        $.ajax({
            url: "http://60.164.210.223:7577/Nvr/map/getXyfz",
            dataType: "jsonp",
            data: {
                nurseId: cardID,
                month: month
            },
            beforeSend: function () {
                placeholder.show(document.body);
            },
            success: function (item) {
                callback(item);
            },
            error: function (error) {
                alert("发展绩效详情请求失败！");
                placeholder.hide(document.body);
                $(".vii-holder-mask").hide();
            }
        });
    }

    /*
    * getBonusPenalty
    * 获取护士奖惩详情数据
    * */
    function getBonusPenalty(cardID, month, callback) {
        $.ajax({
            url: "http://60.164.210.223:7577/Nvr/map/getJCRewardPunishment",
            dataType: "jsonp",
            data: {
                nurseId: cardID,
                month: month
            },
            beforeSend: function () {
                placeholder.show(document.body);
            },
            success: function (item) {
                if (item) {
                    callback(item);
                } else {
                    alert("当前无奖惩详情！");
                    placeholder.hide(document.body);
                    $(".vii-holder-mask").hide();
                }
            },
            error: function (error) {
                alert("奖惩绩效详情请求失败！");
                placeholder.hide(document.body);
                $(".vii-holder-mask").hide();
            }
        });
    }


    /*----------------------------------------- 绩效类 ---------------------------------------------------------------------*/

    /*
    * formatterPerformance
    *  绩效单元格回调
    * */
    function formatterPerformance(row, value, month) {
        var $div = "";
        if (row.name === "岗位绩效") {
            $div = "<div onclick='openJobPerformanceDetails(\"" + row.nurseId + "\",\"" + month + "\")'>" + value + "</div>";
        } else if (row.name === "血源发展绩效") {
            $div = "<div onclick='openDevelopeDetails(\"" + row.nurseId + "\",\"" + month + "\")'>" + value + "</div>";
        } else if (row.name === "奖惩金额") {
            $div = "<div onclick='openBonusPenalty(\"" + row.nurseId + "\",\"" + month + "\")'>" + value + "</div>";
        } else {
            $div = value;
        }
        return $div;
    }


    /*
    * coverTable performance
    * 打开护士绩效框
    * */
    $("#coverTable >.performance").on("click", function () {
        $("#popup").css({
            display: "block",
            width: "1000px"
        });
        autoCenter($("#popup"));
        getPerformanceDetails($("#coverTableSelect").val(), function (item) {
            initPerformance(item);
        })
    });

    /*
    * initPerformance
    * 生成护士绩效框
    * */
    function initPerformance(item) {
        for (var l = item.length; l < 12; l++) {
            item.push({
                baseWages: "",
                postWages: "",
                providerDevWages: "",
                rewardPunishWages: "",
                shouldWages: "",
                actualWages: "",
                month: l + 1
            });
        }
        item.sort(function (a, b) {
            return a.month - b.month;
        });
        var mapping = {
            baseWages: '基本工资',
            postWages: '岗位绩效',
            providerDevWages: '血源发展绩效',
            rewardPunishWages: '奖惩金额',
            shouldWages: '应发工资',
            actualWages: '实发工资'
        };
        var newResult = [];
        for (var key in mapping) {
            var item1, items = {
                name: mapping[key]
            };
            for (var i = 0, len = item.length; i < len; i++) {
                item1 = item[i];
                items['month' + ( i + 1 )] = item1[key];
                items['nurseId'] = $("#coverTableSelect").val();
            }
            newResult.push(items);
        }

        var nurseText = $("#coverTableSelect").find("option:selected").text();
        var nurse = nurseText.substring(0,nurseText.indexOf("【"));
        $("#popup>h1").html("<span style='color:red;'>" + nurse + "</span>绩效详情");
        var html = '<table class="not-pulp performance"></table>';
        $("#popup .popup-content").html(html);
        $("#popup .popup-content table").bootstrapTable('destroy').bootstrapTable({
            cache: false,
            data: newResult,
            undefinedText: "",
            sortName: "month",
            columns: [
                {
                    width: "10%",
                    title: '项目名称',
                    field: "name"
                },
                {
                    width: "7.5%",
                    title: '1月',
                    field: "month1",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "1")
                    }
                },
                {
                    width: "7.5%",
                    title: '2月',
                    field: "month2",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "2")
                    }
                },
                {
                    width: "7.5%",
                    title: '3月',
                    field: "month3",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "3")
                    }
                },
                {
                    width: "7.5%",
                    title: '4月',
                    field: "month4",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "4")
                    }
                },
                {
                    width: "7.5%",
                    title: '5月',
                    field: "month5",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "5")
                    }
                },
                {
                    width: "7.5%",
                    title: '6月',
                    field: "month6",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "6")
                    }
                },
                {
                    width: "7.5%",
                    title: '7月',
                    field: "month7",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "7")
                    }
                },
                {
                    width: "7.5%",
                    title: '8月',
                    field: "month8",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "8")
                    }
                },
                {
                    width: "7.5%",
                    title: '9月',
                    field: "month9",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "9")
                    }
                },
                {
                    width: "7.5%",
                    title: '10月',
                    field: "month10",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "10")
                    }
                },
                {
                    width: "7.5%",
                    title: '11月',
                    field: "month11",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "11")
                    }
                },
                {
                    width: "7.5%",
                    title: '12月',
                    field: "month12",
                    formatter: function (value, row, index) {
                        return formatterPerformance(row, value, "12")
                    }
                }
            ]
        });
        placeholder.hide(document.body);
        $(".vii-holder-mask").hide();
        dragPopup("#popup");
    }

    /*
    * openJobPerformanceDetails
    * 打开护士岗位绩效详情框
    * */
    function openJobPerformanceDetails(nurseId, month) {
        $("#popup1").css({
            display: "block",
            width: "800px"
        });
        autoCenter($("#popup1"));
        getJobPerformanceDetails(nurseId, month, function (item) {
            initJobPerformanceDetails(month, item);
        });
    }

    /*
    * initJobPerformanceDetails
    * 生成岗位绩效详情框
    * */
    function initJobPerformanceDetails(month, item) {
        $("#popup1>h1").html("" + month + "月岗位绩效详情");
        var html = '<table class="not-pulp performance"></table>';
        $("#popup1 .popup-content").html(html);
        $("#popup1 .popup-content table").bootstrapTable('destroy').bootstrapTable({
            cache: false,
            data: item,
            height: item ? (item.length > 10 ? "450" : "300") : "",
            undefinedText: "",
            columns: [
                {
                    width: "8%",
                    title: '序号',
                    field: "",
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    width: "13%",
                    title: '卡号',
                    field: "providerNo",
                    sortable: true
                },
                {
                    width: "20%",
                    title: '浆员姓名',
                    field: "providerName",
                    sortable: true
                },
                {
                    width: "20%",
                    title: '性别',
                    sortable: true,
                    field: "providerSex"
                },
                {
                    width: "24%",
                    title: '日期',
                    sortable: true,
                    field: "date"
                },
                {
                    width: "20%",
                    title: '机器编号',
                    sortable: true,
                    field: "macId"
                }
            ]
        });
        placeholder.hide(document.body);
        $(".vii-holder-mask").hide();
        dragPopup("#popup1");
    }

    /*
   * openDevelopeDetails
   * 打开护士血源发展绩效详情框
   * */
    function openDevelopeDetails(nurseId, month) {
        $("#popup1").css({
            display: "block",
            width: "800px"
        });
        autoCenter($("#popup1"));
        getDevelopeDetails(nurseId, month, function (item) {
            initDevelopeDetails(month, item);
        });
    }


    /*
    * initDevelopeDetails
    * 生成血源发展绩效详情框
    * */
    function initDevelopeDetails(month, item) {
        $("#popup1>h1").html("" + month + "月血源发展绩效详情");
        var html = '<table class="not-pulp performance"></table>';
        $("#popup1 .popup-content").html(html);
        $("#popup1 .popup-content table").bootstrapTable('destroy').bootstrapTable({
            cache: false,
            data: item,
            height: item ? (item.length > 8 ? "400" : "250") : "",
            undefinedText: "",
            columns: [
                {
                    width: "10%",
                    title: '序号',
                    field: "",
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    width: "30%",
                    title: '日期',
                    sortable: true,
                    field: "date"
                },
                {
                    width: "30%",
                    title: '复苏浆员',
                    sortable: true,
                    field: "fsp"
                },
                {
                    width: "30%",
                    title: '新浆员',
                    sortable: true,
                    field: "newP"
                }
            ]
        });

        placeholder.hide(document.body);
        $(".vii-holder-mask").hide();
        dragPopup("#popup1");
    }

    /*
   * openBonusPenalty
   * 打开护士奖惩金额详情框
   * */
    function openBonusPenalty(nurseId, month) {
        $("#popup1").css({
            display: "block",
            width: "800px"
        });
        autoCenter($("#popup1"));
        getBonusPenalty(function (item) {
            initBonusPenalty(month, item);
        });
    }

    /*
    * initBonusPenalty
    * 生成奖惩金额详情框
    * */
    function initBonusPenalty(month, item) {
        $("#popup1>h1").html("" + month + "月奖惩金额详情");
        var html =
            '<table class="not-pulp performance">' +
            '<thead>' +
            '<tr>' +
            '<th style="width: 10%;" >序号</th>' +
            '<th style="width: 20%;">日期</th>' +
            '<th style="width: 10%;">奖惩金额</th>' +
            '<th style="width: 60%;">原因</th>' +
            '</tr>' +
            '</thead>' +
            '</table>';
        $("#popup1 .popup-content").html(html);
        $("#popup1 .popup-content table").bootstrapTable('destroy').bootstrapTable({
            cache: false,
            data: item,
            height: item ? (item.length > 10 ? "450" : "300") : "",
            undefinedText: "",
            columns: [
                {
                    width: "10%",
                    title: '序号',
                    field: "",
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    width: "20%",
                    title: '日期',
                    sortable: true,
                    field: "date"
                },
                {
                    width: "10%",
                    title: '奖惩金额',
                    sortable: true,
                    field: "macId"
                },
                {
                    width: "60%",
                    title: '原因',
                    sortable: true,
                    field: "macId"
                }
            ]
        });
        placeholder.hide(document.body);
        $(".vii-holder-mask").hide();
        dragPopup("#popup1");
    }


</script>
</html>